Skip to content

chore(testing): simplify jest resolver for workspace package imports#32127

Merged
Coly010 merged 1 commit intomasterfrom
chore/simplify-jest-resolver
Aug 12, 2025
Merged

chore(testing): simplify jest resolver for workspace package imports#32127
Coly010 merged 1 commit intomasterfrom
chore/simplify-jest-resolver

Conversation

@ndcunningham
Copy link
Copy Markdown
Contributor

@ndcunningham ndcunningham commented Jul 29, 2025

Current Behavior

Jest module resolution requires manual maintenance of workspace package mappings in moduleNameMapper with brittle relative paths that break across different directory structures.

Expected Behavior

Dynamic workspace package resolution without manual maintenance, using absolute paths that work from any test directory.

Changes

  • Remove all workspace package mappings from jest.preset.js moduleNameMapper
  • Add @nx/* and nx/src/* resolution to patched-jest-resolver.js
  • Use absolute paths and efficient workspace root detection for PNPM
  • Add file vs directory checks to prevent EISDIR errors

References:

ts-jest project references issue: kulshekhar/ts-jest#1648

@vercel
Copy link
Copy Markdown

vercel Bot commented Jul 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview Aug 11, 2025 4:58pm

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Jul 29, 2025

View your CI Pipeline Execution ↗ for commit 868f40b

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 58m 18s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 2m 20s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 4s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 4s View ↗
nx documentation ✅ Succeeded 51s View ↗

☁️ Nx Cloud last updated this comment at 2025-08-11 17:48:13 UTC

@ndcunningham ndcunningham force-pushed the chore/simplify-jest-resolver branch from 415903e to 445bfc2 Compare July 29, 2025 18:06
@ndcunningham ndcunningham self-assigned this Jul 29, 2025
@ndcunningham ndcunningham added the scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx label Jul 29, 2025
@ndcunningham ndcunningham marked this pull request as ready for review July 30, 2025 14:43
@Coly010 Coly010 force-pushed the chore/simplify-jest-resolver branch from 445bfc2 to 5edf7ec Compare August 11, 2025 15:06
@Coly010 Coly010 force-pushed the chore/simplify-jest-resolver branch from 5edf7ec to 868f40b Compare August 11, 2025 16:44
@Coly010 Coly010 merged commit c320f38 into master Aug 12, 2025
4 checks passed
@Coly010 Coly010 deleted the chore/simplify-jest-resolver branch August 12, 2025 08:25
@github-actions
Copy link
Copy Markdown
Contributor

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants